<!--
 * @Author: 卡卡 1071780426@qq.com
 * @Date: 2022-11-05 09:34:27
 * @LastEditors: 贺楠 1071780426@qq.com
 * @LastEditTime: 2024-04-25 16:37:12
 * @FilePath: \mould\src\components\public\el-tree.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->


<template>
  <!-- current-node-key -->
  <!-- ['0fea35c0-6fd2-4825-936d-cff9c00aab38', 'ae54000f-d1b5-4e30-affc-d7533490ba71', 'a3f676d3-d557-4864-9aa2-d452a2dbc85a'] -->
  <el-tree
    :data="treeDatas"
    :props="defaultProps"
    :highlight-current="highlightBd"
    @node-click="handleNodeClick"
    node-key="fCompanyid"
    :accordion="true"
    :expand-on-click-node="false"
    :default-checked-keys="checkData"
    :default-expanded-keys="checkData"
    :current-node-key="checkData[0]"
  ></el-tree>
</template>
<script>
export default {
  props: {
    treeData: {
      type: Array,
      default: () => [],
    },
    checkData: {
      type: Array,
      default: () => [],
    },
    defaultProps: {
      type: Object,
      default: () => {},
    },
    nodeKey: {
      type: String,
      default: "fCompanyid",
    },

    // dataList: {
    //     type: Array,
    //     default: () => {
    //         return []
    //     }
    // },
    // loading: {
    //     type: Boolean,
    //     default: false
    // }
  },
  data() {
    return {
      treeDatas: [],
      // 左侧机构树
      // defaultProps: {
      //     children: "children",
      //     label: "fShortname",
      // },
      highlightBd: true, //左侧机构树停留背景色
    };
  },
  watch: {
    fileDetail: {
      handler(newVal) {
        // console.log(newVal);
        if (newVal) {
          this.pdfUrl = newVal.url;
          this.fFileName = newVal.fFileName;
        }
      },
      immediate: true,
    },
    treeData: {
      handler(newVal) {
        console.log(44,newVal);
        if (newVal) {
          this.treeDatas = newVal
        }
      },
      immediate: true,
    },
  },
  mounted() {},
  methods: {
    handleNodeClick(data) {
      // console.log(data);
      window.sessionStorage.setItem(
        "engineerList",
        JSON.stringify(data)
      );
      this.$emit("getTreeInfo", data);

    },
  },
};
</script>
<style scoped>
.tree {
  height: 100%;
}
</style>
